/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.lm.anotacoes;

import java.io.File;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Robson Motta
 */
@WebServlet(name = "AnnotationServlet", urlPatterns = {"/AnnotationServlet"})
public class AnnotationServlet extends HttpServlet {

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        //Obtem informacão de request GET/POST
        String annotationRequest = request.getParameter("annotationRequest");
        if (annotationRequest != null && !annotationRequest.trim().equals("")) {
            //Processar aqui dados de entrada
        }
        
        //Obtem contexto WEB-INF classes
        String webInfContext = getServletContext().getRealPath(File.separator);

        //Retorna o contexto para o programa chamante
        ObjectOutputStream sendStream = new ObjectOutputStream(response.getOutputStream());
        try {
            sendStream.writeObject(webInfContext);   
        } finally {    
            sendStream.flush();   
            sendStream.close();   
        }    
    }
    
}
